<?php

namespace app\model;

use think\Model;

class ProductAttr extends Model
{
    public function setStock(): array
    {
        $param = request()->post();
        if($param['typs'] == "add"){
            $this->where(['id'=>$param['id']])->inc("stock",$param['stock'])->save();
        } else {
            $this->where(['id'=>$param['id']])->dec("stock",$param['stock'])->save();
        }

        return $this->toArray();
    }
}
